﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace MidSoft.Web.Model_T_PET_OWENER
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				#warning 代码生成提示：显示页面,请检查确认该语句是否正确
				ShowInfo();
			}
		}
			
	private void ShowInfo()
	{
		MidSoft.BLL.BLL_T_PET_OWENER bll=new MidSoft.BLL.BLL_T_PET_OWENER();
		MidSoft.Model.Model_T_PET_OWENER model=bll.GetModel();
		this.txtPET_OWENER_ID.Text=model.PET_OWENER_ID;
		this.txtADDRESS.Text=model.ADDRESS;
		this.txtBIRTHDAY.Text=model.BIRTHDAY.ToString();
		this.txtCARD_ID.Text=model.CARD_ID;
		this.txtCARD_TYPE.Text=model.CARD_TYPE.ToString();
		this.txtEMAIL.Text=model.EMAIL;
		this.txtMOBILE.Text=model.MOBILE;
		this.txtNOTE.Text=model.NOTE;
		this.txtORG_NAME.Text=model.ORG_NAME;
		this.txtPER_NAME.Text=model.PER_NAME;
		this.txtPHONE.Text=model.PHONE;
		this.txtPOST_NUM.Text=model.POST_NUM;
		this.txtREG_ORG_ID.Text=model.REG_ORG_ID;
		this.txtSEX.Text=model.SEX;
		this.txtIS_SMS.Text=model.IS_SMS;
		this.txtSTATE.Text=model.STATE;
		this.txtTYPE.Text=model.TYPE.ToString();
		this.txtIS_EMAIL.Text=model.IS_EMAIL;
		this.txtIS_MAIL.Text=model.IS_MAIL;
		this.txtCREATE_TIME.Text=model.CREATE_TIME.ToString();
		this.txtCREATOR_ID.Text=model.CREATOR_ID;
		this.txtUPDATE_TIME.Text=model.UPDATE_TIME.ToString();
		this.txtUPDATOR_ID.Text=model.UPDATOR_ID;
		this.txtID.Text=model.ID.ToString();

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtPET_OWENER_ID.Text.Trim().Length==0)
			{
				strErr+="ID不能为空！\\n";	
			}
			if(this.txtADDRESS.Text.Trim().Length==0)
			{
				strErr+="地址。不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtBIRTHDAY.Text))
			{
				strErr+="生日。格式错误！\\n";	
			}
			if(this.txtCARD_ID.Text.Trim().Length==0)
			{
				strErr+="证件号。不能为空！\\n";	
			}
			if(!PageValidate.IsDecimal(txtCARD_TYPE.Text))
			{
				strErr+="证件类型。格式错误！\\n";	
			}
			if(this.txtEMAIL.Text.Trim().Length==0)
			{
				strErr+="电子邮件。不能为空！\\n";	
			}
			if(this.txtMOBILE.Text.Trim().Length==0)
			{
				strErr+="手机。不能为空！\\n";	
			}
			if(this.txtNOTE.Text.Trim().Length==0)
			{
				strErr+="备注。不能为空！\\n";	
			}
			if(this.txtORG_NAME.Text.Trim().Length==0)
			{
				strErr+="组织名。不能为空！\\n";	
			}
			if(this.txtPER_NAME.Text.Trim().Length==0)
			{
				strErr+="属主名。不能为空！\\n";	
			}
			if(this.txtPHONE.Text.Trim().Length==0)
			{
				strErr+="电话。不能为空！\\n";	
			}
			if(this.txtPOST_NUM.Text.Trim().Length==0)
			{
				strErr+="邮编。不能为空！\\n";	
			}
			if(this.txtREG_ORG_ID.Text.Trim().Length==0)
			{
				strErr+="注册机构ID。不能为空！\\n";	
			}
			if(this.txtSEX.Text.Trim().Length==0)
			{
				strErr+="性别。不能为空！\\n";	
			}
			if(this.txtIS_SMS.Text.Trim().Length==0)
			{
				strErr+="是否发短信。不能为空！\\n";	
			}
			if(this.txtSTATE.Text.Trim().Length==0)
			{
				strErr+="状态。不能为空！\\n";	
			}
			if(!PageValidate.IsDecimal(txtTYPE.Text))
			{
				strErr+="类别。格式错误！\\n";	
			}
			if(this.txtIS_EMAIL.Text.Trim().Length==0)
			{
				strErr+="是否发电邮。不能为空！\\n";	
			}
			if(this.txtIS_MAIL.Text.Trim().Length==0)
			{
				strErr+="是否发邮件。不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtCREATE_TIME.Text))
			{
				strErr+="创建时间。格式错误！\\n";	
			}
			if(this.txtCREATOR_ID.Text.Trim().Length==0)
			{
				strErr+="创建人ID。不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtUPDATE_TIME.Text))
			{
				strErr+="更新时间。格式错误！\\n";	
			}
			if(this.txtUPDATOR_ID.Text.Trim().Length==0)
			{
				strErr+="更新人ID。不能为空！\\n";	
			}
			if(!PageValidate.IsDecimal(txtID.Text))
			{
				strErr+="原ID格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			string PET_OWENER_ID=this.txtPET_OWENER_ID.Text;
			string ADDRESS=this.txtADDRESS.Text;
			DateTime BIRTHDAY=DateTime.Parse(this.txtBIRTHDAY.Text);
			string CARD_ID=this.txtCARD_ID.Text;
			decimal CARD_TYPE=decimal.Parse(this.txtCARD_TYPE.Text);
			string EMAIL=this.txtEMAIL.Text;
			string MOBILE=this.txtMOBILE.Text;
			string NOTE=this.txtNOTE.Text;
			string ORG_NAME=this.txtORG_NAME.Text;
			string PER_NAME=this.txtPER_NAME.Text;
			string PHONE=this.txtPHONE.Text;
			string POST_NUM=this.txtPOST_NUM.Text;
			string REG_ORG_ID=this.txtREG_ORG_ID.Text;
			string SEX=this.txtSEX.Text;
			string IS_SMS=this.txtIS_SMS.Text;
			string STATE=this.txtSTATE.Text;
			decimal TYPE=decimal.Parse(this.txtTYPE.Text);
			string IS_EMAIL=this.txtIS_EMAIL.Text;
			string IS_MAIL=this.txtIS_MAIL.Text;
			DateTime CREATE_TIME=DateTime.Parse(this.txtCREATE_TIME.Text);
			string CREATOR_ID=this.txtCREATOR_ID.Text;
			DateTime UPDATE_TIME=DateTime.Parse(this.txtUPDATE_TIME.Text);
			string UPDATOR_ID=this.txtUPDATOR_ID.Text;
			decimal ID=decimal.Parse(this.txtID.Text);


			MidSoft.Model.Model_T_PET_OWENER model=new MidSoft.Model.Model_T_PET_OWENER();
			model.PET_OWENER_ID=PET_OWENER_ID;
			model.ADDRESS=ADDRESS;
			model.BIRTHDAY=BIRTHDAY;
			model.CARD_ID=CARD_ID;
			model.CARD_TYPE=CARD_TYPE;
			model.EMAIL=EMAIL;
			model.MOBILE=MOBILE;
			model.NOTE=NOTE;
			model.ORG_NAME=ORG_NAME;
			model.PER_NAME=PER_NAME;
			model.PHONE=PHONE;
			model.POST_NUM=POST_NUM;
			model.REG_ORG_ID=REG_ORG_ID;
			model.SEX=SEX;
			model.IS_SMS=IS_SMS;
			model.STATE=STATE;
			model.TYPE=TYPE;
			model.IS_EMAIL=IS_EMAIL;
			model.IS_MAIL=IS_MAIL;
			model.CREATE_TIME=CREATE_TIME;
			model.CREATOR_ID=CREATOR_ID;
			model.UPDATE_TIME=UPDATE_TIME;
			model.UPDATOR_ID=UPDATOR_ID;
			model.ID=ID;

			MidSoft.BLL.BLL_T_PET_OWENER bll=new MidSoft.BLL.BLL_T_PET_OWENER();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
